<?php
$section = "product";
$titre = _LB_PRODUCTS;
$link = $section;
Session::setBackLink($link);
//create cfer
$rootPath = array(
	_LB_HOME => APPLICATION_URL_FO,
    _LB_PRODUCTS => APPLICATION_URL_FO."/products/");
$id = Request::getNumber("id");
$product = new Product();
if( !($id > 0) || !$product->get($id)){
    redirect(APPLICATION_DIR_FO);
}
$titre .= TITLE_PAGE_SEPARATE . $product->NAME;
$productInfo = new Product_Info();
$productInfo->ID_PRODUCT = $id;
$productInfo->find();

$productInfoTitle = new Product_Info();
$productInfoTitle->ID_PRODUCT = $id;
$productInfoTitle->find();

$pDownload = new Product_Download();
$pDownload->ID_PRODUCT = $id;
$pDownload->find();

$pImage = new Product_Image();
$pImage->ID_PRODUCT = $id;
$pImage->find();

$catID = $product->ID_CATEGORY;

$path = array($catID);
Category::getCategoryPath($catID, $path);
$arrCat = array();
Category::getAllSubItem(0, $arrCat, $path);

$pathName = array();
Category::getCategoryNamePath($product->ID_CATEGORY, $pathName);
$utils = new Utils();
for($i = count($pathName);$i>=0;$i--){
    if(isset($pathName[$i]) && is_array($pathName[$i])){
        $item = $pathName[$i];
        $rootPath[$item['TITLE']] = APPLICATION_URL_FO."/products/category/".$item['ID']."/". $utils->RemoveSign($item['TITLE']);    
    }
}
$cfer = new Cfer($rootPath);

Session::setBackCfer($link, $cfer->getCferArray());
$smarty->assign('cfer', $cfer);
$smarty->assign('catLeft', $arrCat);
$smarty->assign('product', $product);
$smarty->assign('pInfoTitle', $productInfoTitle);
$smarty->assign('pInfo', $productInfo);
$smarty->assign('pDownload', $pDownload);
$smarty->assign('pImage', $pImage);
$smarty->assign('id', $id);
$smarty->assign('titre', $titre);
$smarty->display("products_detail.html");